icontheme: Optimize memory use and lookup speed by internalizing icon names
authorAlexander Larsson <alexl@redhat.com>
Fri, 7 Feb 2020 10:54:00 +0000 (11:54 +0100)
committerAlexander Larsson <alexl@redhat.com>
Fri, 7 Feb 2020 11:00:52 +0000 (12:00 +0100)
commitbdbafe63f96b9fc9713ff8edb094f49b2c31a713
tree82e4caa211e72c65603019f10f3a567c06b234e1
parent2be29f982d9681b563f71dfb16faa261fc3c10b5
icontheme: Optimize memory use and lookup speed by internalizing icon names

Instead of having the IconTheme have a hashtable that owns
individual strings and then IconThemeDirSize have a similar
hash (but with the strings owned by the other hash), we
have a consecutive memory chunks where we store the icon names
and then the hashtable has pointers into this.

This means we can avoid a bunch of individual strdup()s in a
way that is less fragmented and wastes less space. Additionally,
since we do an initial lookup anyway we have the internalized
icon name during lookup which means we can use g_direct_hash/equal
instead of g_str_hash/equal making the lookup faster too.
gtk/gtkiconcache.c
gtk/gtkiconcacheprivate.h
gtk/gtkicontheme.c
gtk/gtkiconthemeprivate.h